﻿using Microsoft.AspNetCore.Mvc;
using Shop.Core.Share;
using Shop.IServices;
using Shop.Model.Dto.Mine;
using Shop.Model.View.Mine;

namespace Shop.WebApi.Controllers;

/// <summary>
/// 我的页面
/// </summary>
[ApiController]
[Route("Api/[controller]")]
public class MineController: ShopControllerBase
{
    private readonly IMineService _mineService;
    private readonly IUserContext _userContext;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="mineService"></param>
    /// <param name="userContext"></param>
    public MineController(IMineService mineService,IUserContext userContext)
    {
        _mineService = mineService;
        _userContext = userContext;
    }

    /// <summary>
    /// 我的业绩
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Performance")]
    public AppResult<PerformanceVo> Performance()
    {
        try
        {
            return _mineService.Performance(_userContext.Id);
        }
        catch (Exception ex)
        {
            return Problem(ex.Message.ToString());
        }
    }

    /// <summary>
    /// 我的礼包业绩数据
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("GiftBagData")]
    public AppResult<GiftBagDataVo> GiftBagData()
        => _mineService.GiftBagData(_userContext.Id);

    /// <summary>
    /// 我的订单
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Order")]
    public AppResult<MyOrderVo> MyOrder()
        => _mineService.MyOrder(_userContext.Id);

    /// <summary>
    /// 我的钱包
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Wallet")]
    public AppResult<MyWalletVo> MyWallet()
        => _mineService.MyWallet(_userContext.Id);

    /// <summary>
    /// 我的收益
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Earnings")]
    public AppResult<MyEarningsVo> MyEarnings()
        => _mineService.MyEarnings(_userContext.Id);

    /// <summary>
    /// 我的销售
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Market")]
    public AppResult<MyMarketVo> MyMarket()
        => _mineService.MyMarket(_userContext.Id);

    /// <summary>
    /// 我的顾客
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Customer")]
    public AppResult<MyCustomerVo> MyCustomer()
        => _mineService.MyCustomer(_userContext.Id);

    /// <summary>
    /// 我的上级
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("Superior")]
    public AppResult<MySuperiorVo> MySuperior()
        => _mineService.MySuperior(_userContext.Id);
}